import { Controller, Inject, Get, Query } from '@midwayjs/core';
import { UserInfoService } from "@service/common/userInfo.service";
import { GetRouterService } from "@service/common/getRouters.service";
import { GetCodeService } from "@service/common/originCode.service";
import { OriginCodeDTO } from "@dto/common/originCode.dto";

@Controller('/')
export class IndexController {

  @Inject()
  userInfoService: UserInfoService;

  @Inject()
  getRouterService: GetRouterService;

  @Inject()
  getCodeService: GetCodeService;

  @Get('/')
  async home(): Promise<string> {
    return '大家好，我是渣渣瑞!本项目是若依后台的nodejs版本，基于midway框架来实现。用到了：Typescript、typeorm、mysql、jwt、redis等技术';
  }

  // 获取用户信息
  @Get('/getInfo')
  async getInfo(): Promise<any> {
    return this.userInfoService.getUserInfo();
  }

  // 获取路由表
  @Get('/getRouters')
  async getRouters() {
    return this.getRouterService.getRouters();
  }

  // 获取源代码
  @Get('/getOriginCode')
  async getCode(@Query() body: OriginCodeDTO) {
    return this.getCodeService.getCode(body);
  }
}
